package com.google.appengine.a4ieve;


import org.json.JSONArray;
import org.json.JSONObject;

public enum StudentGroup {
    BOREAS("boreas", "Boreas"),
    NOTUS("notus", "Notus"),
    ZEPHYRUS("zephyrus", "Zephyrus"),
    EURUS("eurus", "Eurus");

    private String groupName;
    private String displayedName;

    StudentGroup(String g, String d) {
        this.groupName = g;
        this.displayedName = d;
    }

    public String getGroupName() {
        return this.groupName;
    }

//    public static String render() {
//        StringBuilder output = new StringBuilder("<span class=\"acheivement-title\">Choose group: " +
//                "</span>&nbsp;<select name=\"student_group\">");
//        for (StudentGroup group : values()) {
//            output.append("<option value=\"").append(group.groupName).append("\">")
//                    .append(group.displayedName).append("</option>");
//        }
//        output.append("</select>");
//        return output.toString();
//    }

    private static final JSONArray JSON_REPRESENTATION;

    static {
        JSONArray objects = new JSONArray();
        for (StudentGroup a : values()) {
            JSONObject object = new JSONObject();
            object.put(Const.TYPE, a.groupName);
            object.put(Const.NAME, a.displayedName);
            objects.put(object);
        }
        JSON_REPRESENTATION = objects;
    }

    public static JSONArray getRepresentation() {
        return JSON_REPRESENTATION;
    }
}
